call <- function(S, K, P) {
	ifelse(S > K, S - K - P, -P)
}
D <- 50
callpayl <- call(seq(D - 10,D + 20), D - 0.5, 0)
callpays <- -call(seq(D - 10,D + 20), D + 0.5, 0)

plot(seq(D - 10,D + 20),callpayl,type ="l",col="red",ylim=c(-0.5,2), xlab="Terminal Option Price",ylab="Terminal profit")
lines(seq(D - 10,D + 20), callpays, col="blue")
lines(seq(D - 10,D + 20), callpays + callpayl, col="green")
legend(40,1.75,c("Pay off long call", "Pay off short call", "Pay off digital option"), col=c("red", "blue", "green"),lty=c(1,1,1))
